<%--
  Created by IntelliJ IDEA.
  User: ming
  Date: 2021/11/19
  Time: 19:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fm" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>首页</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
          integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
            integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd"
            crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">

            <a class="btn btn-success" role="button" href="/addEmp.jsp">新增</a>
            <table class="table table-bordered table-hover table-striped">
                <thead>
                <tr>
                    <td>员工编号</td>
                    <td>姓名</td>
                    <td>性别</td>
                    <td>工资</td>
                    <td>密码</td>
                    <td>部门编号</td>
                    <td>出入日期</td>
                    <td>联系方式</td>
                    <td>操作</td>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${empInfo.list}" var="e">
                    <tr>
                        <td>${e.eno}</td>
                        <td>${e.ename}</td>
                        <td>${e.esex}</td>
                        <td>${e.salary}</td>
                        <td>${e.pwd}</td>
                        <td>${e.dno}</td>
                        <td>
                            <fm:formatDate value="${e.bornDate}" pattern="yyyy年MM月dd日"/>
                        </td>
                        <td>${e.phone}</td>
                        <td>
                            <a class="btn btn-warning" role="button" href="/emp/getEmpByEno?eno=${e.eno}">修改</a>
                            <button class="delBtn btn btn-danger">删除</button>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
                <tfoot>
                <tr class="text-center">
                    <td colspan="9">
                        <nav aria-label="Page navigation">
                            <ul class="pagination">
                                <li>
                                    <a href="/emp/index?pageIndex=${empInfo.pageNum-1}" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                                <c:forEach items="${empInfo.navigatepageNums}" var="i">
                                    <li><a href="/emp/index?pageIndex=${i}">${i}</a></li>
                                </c:forEach>
                                <li>
                                    <a href="/emp/index?pageIndex=${empInfo.pageNum+1}" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                            </ul>
                        </nav>
                    </td>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>
<script>
    $(function () {
        $(".delBtn").click(function () {
            let c = $(this).parents("tr").children().first().text();
            if (confirm("是否确认删除?")) {
                location.href = "/emp/delEmp?eno=" + c;
            }
        })
    })
</script>
</body>
</html>
